load("@prelude//erlang:erlang_toolchain.bzl", "erlang_parse_transform", "toolchain_utilities")
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

erlang_parse_transform(
    name = "transform_project_root",
    src = "transform_project_root.erl",
    visibility = ["PUBLIC"],
)

# export escripts for testing
filegroup(
    name = "util_scripts",
    srcs = glob([
        "*.escript",
        "*.sh",
        "*.erl",
    ]),
    visibility = ["PUBLIC"],
)

toolchain_utilities(
    name = "toolchain_utilities",
    app_src_script = "app_src_builder.erl",
    boot_script_builder = "boot_script_builder.erl",
    core_parse_transforms = [":transform_project_root"],
    dependency_analyzer = "dependency_analyzer.erl",
    dependency_finalizer = "dependency_finalizer.erl",
    dependency_merger = "dependency_merger.erl",
    erlc_trampoline = "erlc_trampoline.sh",
    escript_builder = "escript_builder.erl",
    escript_trampoline = "escript_trampoline.sh",
    extract_from_otp = "extract_from_otp.erl",
    release_variables_builder = "release_variables_builder.erl",
    utility_modules = ["dependency_utils.erl"],
    visibility = ["PUBLIC"],
)
